package org.jeecg.modules.iot.middleware.processor.carOperate;


import org.jeecg.jt808.JTT808Encoder;
import org.jeecg.jt808.JTT808Message;
import org.jeecg.jt808.vo.Packet;
import org.jeecg.modules.iot.model.Jt808Control.Jt808CentralControlConfig;
import org.jeecg.modules.iot.model.modbus.ModbusParams;
import org.jeecg.modules.iot.middleware.processor.JT808MessageGenerator;
import org.jeecg.modules.iot.middleware.processor.MessageType;
import org.springframework.stereotype.Component;

import static org.jeecg.modules.iot.middleware.util.JT808Utils.bytesToHexString;


@Component
public class HandleLockCloseMessageGenerator implements JT808MessageGenerator {
    @Override
    public String generateMessage(JTT808Message message) {
        byte controlCommand = 0x00; // 车辆控制指令，龙头锁指令
        byte controlParameter = 0x08; // 关锁，对应 BYTE 2, 位 3
        message.packetCount = 0;
        message.packetIndex = 0;
        message.id = 0x8500;
        Packet p = Packet.create(2);
        p.addByte(controlCommand);
        p.addByte(controlParameter);
        message.body = p.getBytes();
        return bytesToHexString(JTT808Encoder.encode(message));
    }

    @Override
    public String generateMessage(JTT808Message message, Jt808CentralControlConfig config) {
        return "";
    }

    @Override
    public String generateMessage(JTT808Message message, ModbusParams params) {
        return "";
    }

    @Override
    public String getType() {
        return MessageType.HANDLE_LOCK_CLOSE.name();
    }
}